Public Partial Class GaleriaDeFotos
    Inherits System.Web.UI.Page
    Protected script As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            EncheGrid()

        End If
    End Sub
    Private Sub EncheGrid()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Album
        Try
            datalistAlbum.DataSource = c.getTodosRegistros
            datalistAlbum.DataBind()

        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
        End Try
    End Sub
    Private Sub mostraregistro()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Album
        Try

            c.IDAlbum = Val(txtIDAlbum.Text)
            c.carregar()
            lblAlbum.Text = c.Nome ' na tabela envia fotos
        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
        End Try
    End Sub

    Protected Sub datalistAlbum_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles datalistAlbum.SelectedIndexChanged
        Dim lbl As Label
        lbl = datalistAlbum.Items(datalistAlbum.SelectedIndex).FindControl("lblID")
        txtIDAlbum.Text = lbl.Text
        mostraregistro()
        tbAlbum.Visible = False
        tbFotos.Visible = True
        MostraFotos()
    End Sub
    Private Sub MostraFotos()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Fotos
        Try
            c.addWhere("IDAlbum", ClasseBase.Classes.PersistClass.TipoFiltro.Igual, Val(txtIDAlbum.Text))
            DataListFotos.DataSource = c.getTodosRegistros
            DataListFotos.DataBind()

        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
        End Try
    End Sub

    Protected Sub btnLimpar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLimpar.Click
        Response.Redirect(Request.Path)

    End Sub

    Protected Sub DataListFotos_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataListFotos.SelectedIndexChanged
        Dim img As ImageButton
        Dim fun As New Funcoes
        img = DataListFotos.Items(DataListFotos.SelectedIndex).FindControl("ImageButton2")
        script += fun.AbreRelatorio(img.ImageUrl, "Imagem")
        ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "msg", script, False)
        fun = Nothing

    End Sub
End Class